import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { DiningTableTypeApi } from '#/api/spa/dining/tabletype';

import { z } from '#/adapter/form';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';

import { DICT_SPA_TYPE } from '#/utils/dictSpa';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'groupId',
      label: '集团ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入集团ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'restaurantId',
      label: '餐厅ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入餐厅ID',
      },
    },
    {
      fieldName: 'typeCode',
      label: '类型编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入类型编码',
      },
    },
    {
      fieldName: 'typeName',
      label: '类型名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入类型名称',
      },
    },
    {
      fieldName: 'typeDescription',
      label: '类型描述',
      component: 'RichTextarea',
    },
    {
      fieldName: 'defaultCapacity',
      label: '默认容纳人数',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入默认容纳人数',
      },
    },
    {
      fieldName: 'minCapacity',
      label: '最小容纳人数',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入最小容纳人数',
      },
    },
    {
      fieldName: 'maxCapacity',
      label: '最大容纳人数',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入最大容纳人数',
      },
    },
    {
      fieldName: 'tableShape',
      label: '餐桌形状',
      component: 'Input',
      componentProps: {
        placeholder: '请输入餐桌形状',
      },
    },
    {
      fieldName: 'scope',
      label: '权限范围',
      component: 'Input',
      componentProps: {
        placeholder: '请输入权限范围',
      },
    },
    {
      fieldName: 'scoperef',
      label: '权限引用',
      component: 'Input',
      componentProps: {
        placeholder: '请输入权限引用',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'groupId',
      label: '集团ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入集团ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'restaurantId',
      label: '餐厅ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入餐厅ID',
      },
    },
    {
      fieldName: 'typeCode',
      label: '类型编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入类型编码',
      },
    },
    {
      fieldName: 'typeName',
      label: '类型名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入类型名称',
      },
    },
    {
      fieldName: 'typeDescription',
      label: '类型描述',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入类型描述',
      },
    },
    {
      fieldName: 'defaultCapacity',
      label: '默认容纳人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入默认容纳人数',
      },
    },
    {
      fieldName: 'minCapacity',
      label: '最小容纳人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入最小容纳人数',
      },
    },
    {
      fieldName: 'maxCapacity',
      label: '最大容纳人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入最大容纳人数',
      },
    },
    {
      fieldName: 'tableShape',
      label: '餐桌形状',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入餐桌形状',
      },
    },
    {
      fieldName: 'scope',
      label: '权限范围',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入权限范围',
      },
    },
    {
      fieldName: 'scoperef',
      label: '权限引用',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入权限引用',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<DiningTableTypeApi.DiningTableType>['columns'] {
  return [
    {
      field: 'id',
      title: '主键ID',
      minWidth: 120,
    },
    {
      field: 'groupId',
      title: '集团ID',
      minWidth: 120,
    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,
    },
    {
      field: 'restaurantId',
      title: '餐厅ID',
      minWidth: 120,
    },
    {
      field: 'typeCode',
      title: '类型编码',
      minWidth: 120,
    },
    {
      field: 'typeName',
      title: '类型名称',
      minWidth: 120,
    },
    {
      field: 'typeDescription',
      title: '类型描述',
      minWidth: 120,
    },
    {
      field: 'defaultCapacity',
      title: '默认容纳人数',
      minWidth: 120,
    },
    {
      field: 'minCapacity',
      title: '最小容纳人数',
      minWidth: 120,
    },
    {
      field: 'maxCapacity',
      title: '最大容纳人数',
      minWidth: 120,
    },
    {
      field: 'tableShape',
      title: '餐桌形状',
      minWidth: 120,
    },
    {
      field: 'scope',
      title: '权限范围',
      minWidth: 120,
    },
    {
      field: 'scoperef',
      title: '权限引用',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
